1. Technical Field
The present invention provides an improved data processing system and in particular the present invention provides a method and apparatus for memory management in a data processing system. Still more particularly, the present invention provides a method and apparatus for freeing memory in a data processing system.
2. Description of Related Art
In object oriented systems, data and methods are integrated into objects. An object includes data of arbitrary length and a method of arbitrary length. As a result, management of objects in an object oriented environment, in such a system requires an ability to manage memory areas of variable size. When the entire memory space has been used through allocation of memory space for objects, it becomes necessary to collect unused areas in the memory to provide memory space as another resource. Garbage collection is performed by a garbage collector to reclaim the memory space used by objects that are no longer referenced by an application.
Such a garbage management collection is important when a virtual machine, such as a Java virtual machine, needs additional free memory to be allocated for an object. The memory area typically managed for objects is called a heap. The allocation and freeing of memory in a heap is usually allocated and freed in set blocks. A single heap exists within a Java virtual machine instance. A separate heap, however, exists for each instance of the Java virtual machine. Since each application is associated with a single instance of a Java virtual machine, two Java applications will not trample or use each other""s heap data. The Java virtual machine has instructions to allocate memory on the heap for a new object, but includes no instruction for freeing that memory. The Java virtual machine is responsible, however, to decide whether and when to free memory occupied by objects no longer referenced by the running application. Even with a garbage collector, it is possible to have a situation in which a sufficient amount of memory is unavailable when allocating a new object. This situation may arise when objects still being referenced by an application consume all of the available memory within the heap. With the increasing size of applications and objects and the limited amount of memory on different types of computers, such a situation is likely. If memory is unavailable to allocate the new object, the Java virtual machine is unable to proceed and execution is halted.
Therefore it would be advantageous to have an improved method and apparatus for managing memory in a data processing system.
The present invention provides a method and apparatus in a computer freeing space in a memory, wherein a plurality of objects are present within the memory. Responsive to an indication that space needs to be freed in the memory, an object is identified within the plurality of objects that is an oldest, least recently used object that is in use in the memory, wherein the object is an identified object and has a set of object attributes. The set of object attributes is inspected for the identified object to determine Whether the identified object is a candidate for storage in a seldom used object store. Responsive to a determination that the identified object is a candidate, the object is copied to the seldom used object store, wherein the identified object becomes a relocated object. References to the relocated object to a location of the relocated object in the seldom used object store are adjusted. Space is freed in the memory occupied by the relocated object.